home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F40966_scanlDVC.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-03-16  |  2.7 KB  |  75 lines

  1. <xsl:stylesheet version="1.0" 
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xalan="http://xml.apache.org/xalan"
  4. exclude-result-prefixes="xsl xalan"
  5. >
  6.   <xsl:template name="scanl">
  7.     <xsl:param name="pFun" select="/.."/>
  8.     <xsl:param name="pQ0" select="/.."/>
  9.     <xsl:param name="pList" select="/.."/>
  10.     <xsl:param name="pElName" select="'el'"/>
  11.     <xsl:param name="pStarting" select="1"/>
  12.     
  13.     <xsl:variable name="vLength" select="count($pList)"/>
  14.  
  15.     <xsl:choose>
  16.       <xsl:when test="$vLength > 1">
  17.         <xsl:variable name="vHalf" select="floor($vLength div 2)"/>
  18.           
  19.         <xsl:variable name="vrtfResult1">
  20.               <xsl:call-template name="scanl">
  21.                     <xsl:with-param name="pFun" select="$pFun"/>
  22.                     <xsl:with-param name="pQ0" select="$pQ0" />
  23.                     <xsl:with-param name="pList" select="$pList[position() <= $vHalf]"/>
  24.                     <xsl:with-param name="pElName" select="$pElName"/>
  25.             <xsl:with-param name="pStarting" select="$pStarting"/>
  26.               </xsl:call-template>
  27.           </xsl:variable>
  28.           
  29.           <xsl:variable name="vResult1" select="xalan:node-set($vrtfResult1)/*"/>
  30.           
  31.           <xsl:copy-of select="$vResult1"/>
  32.           
  33.           <xsl:call-template name="scanl">
  34.                 <xsl:with-param name="pFun" select="$pFun"/>
  35.                 <xsl:with-param name="pQ0" select="$vResult1[last()]" />
  36.                 <xsl:with-param name="pList" select="$pList[position() > $vHalf]"/>
  37.                 <xsl:with-param name="pElName" select="$pElName"/>
  38.           <xsl:with-param name="pStarting" select="0"/>
  39.           </xsl:call-template>
  40.       </xsl:when>
  41.  
  42.       <xsl:otherwise>
  43.             <xsl:if test="$pStarting">
  44.                 <xsl:element name="{$pElName}">
  45.                   <xsl:copy-of select="xalan:node-set($pQ0)/node()"/>
  46.                 </xsl:element>
  47.             </xsl:if>
  48.     
  49.         <xsl:if test="$pList">
  50.                 <xsl:element name="{$pElName}">
  51.                   <xsl:apply-templates select="$pFun">
  52.                     <xsl:with-param name="pArg1" select="$pQ0"/>
  53.                     <xsl:with-param name="pArg2" select="$pList[1]"/>
  54.                   </xsl:apply-templates>
  55.                 </xsl:element>
  56.         </xsl:if>
  57.       </xsl:otherwise>
  58.     </xsl:choose>
  59.   </xsl:template>
  60.   
  61.   <xsl:template name="scanl1">
  62.     <xsl:param name="pFun" select="/.."/>
  63.     <xsl:param name="pList" select="/.."/>
  64.     <xsl:param name="pElName" select="'el'"/>
  65.     
  66.     <xsl:if test="$pList">
  67.       <xsl:call-template name="scanl">
  68.         <xsl:with-param name="pFun" select="$pFun"/>
  69.         <xsl:with-param name="pQ0" select="$pList[1]" />
  70.         <xsl:with-param name="pList" select="$pList[position() > 1]"/>
  71.         <xsl:with-param name="pElName" select="$pElName"/>
  72.       </xsl:call-template>
  73.     </xsl:if>
  74.   </xsl:template>
  75. </xsl:stylesheet>